import { get, post, put, del } from '@/utils/http/request'
import { R, P } from '@/utils/http/type'

export interface Tree {
  id: string
  title: string
  children: Tree[]
}
// 获取所有菜单权限树结构
export const getAllTree = () => {
  return get<R<Tree[]>>('/permission/all/tree')
}
/**
 * 当前角色下拥有的菜单
 * @param id  用户id
 * @returns
 */
export const getRoleDetail = (id: number) => {
  return get<R<number[]>>(`/role/permission/relation/pids/${id} `)
}
/**
 * 获取角色tree选中节点
 * @param data
 * @returns
 */
export const getTreeDetail = (id: number) => {
  return get<R<number[]>>(`/role/permission/relation/check/pids/${id} `)
}

export const updataRoleJurisdiction = (data: any) => {
  return put<R<any>>('/role/permission/relation', data)
}
